package com.example.demo.system.controller;

import com.example.demo.system.entity.UserRole;
import com.example.demo.system.service.UserRoleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
/**
* @author 许久龙
* @since 2022-02-19
*/
@RestController
@RequestMapping("api")
public class UserRoleController {

    @Autowired
    private UserRoleService userRoleService;

    @GetMapping("/user-role")
    @ApiOperation("UserRole查询单个")
    public ResultVO getUserRole(@RequestBody UserRole userRole){
     ResultVO resultVO = userRoleService.getUserRole(UserRole userRole);
     return  resultVO;
   }

    @GetMapping("/user-role")
    @ApiOperation("UserRole查询全部")
    public ResultVO getAllUserRole(){
        ResultVO resultVO = userRoleService.getAllUserRole();
        return  resultVO;
    }

    @PostMapping("/user-role")
    @ApiOperation("UserRole新增")
    public ResultVO add(@Valid @RequestBody UserRole userRole) {
        ResultVO resultVO = userRoleService.add(UserRole userRole);
        return  resultVO;
    }

    @PutMapping("/user-role")
    @ApiOperation("UserRole修改")
    public ResultVO update(@Valid @RequestBody UserRole userRole) {
        ResultVO resultVO = userRoleService.update(UserRole userRole);
        returnresultVO;
    }


    @DeleteMapping(value = "/user-role/{ids}")
    @ApiOperation("UserRole删除(单个条目)")
    public ResultVO remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        ResultVO resultVO = userRoleService.remove(String ids);
        return resultVO;
    }
}
